//
//  EXQuery.h
//  ORM
//
//  Created by PH on 21.12.09.
//  Copyright 2009-2010 Codesign. All rights reserved.
//

#import <Foundation/Foundation.h>

#define EXQUERY(param, expr, ...) [[[EXQuery alloc] initWithBlock: (BOOL(^)(id)) ^BOOL(param) { return expr; }\
	paramString: [NSString stringWithUTF8String: #param]\
	queryString: [NSString stringWithUTF8String: #expr]\
	varNamesList: [NSString stringWithUTF8String: #__VA_ARGS__], ##__VA_ARGS__] autorelease]

@interface EXQuery : NSObject {
	BOOL(^block)(id);
	NSString* className;
	NSString* objectVar;
	NSPredicate* predicate;
	NSMutableDictionary* localVars;
}

- (id)initWithBlock:(BOOL(^)(id))_block paramString:(NSString*)paramString queryString:(NSString*)queryString varNamesList:(NSString*)varNamesList, ...;
- (BOOL(^)(id))block;
- (NSString*)predicateQuery:(NSString*)query objects:(NSSet**)objects;
- (NSPredicate*)predicate;
- (NSDictionary*)localVars;
- (NSString*)objectVar;

@end
